﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Collections;
using JXT.PrimaryKey.Batman.Domain.Services;
using JXT.PrimaryKey.Batman.Domain.Quotation.Models;
using JXT.PrimaryKey.Batman.Domain.Specifications;

namespace JXT.PrimaryKey.Batman.Domain.Quotation.Services
{
    /// <summary>
    /// 股票代码历史行情服务接口
    /// </summary>
    public interface IMarketStatisticService : ICachedService
    {
        /// <summary>
        /// 根据给出条件查询单个日行情数据
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>日行情数据</returns>
        MarketStatistic GetSingle(ISpecification<MarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询日行情集合
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>日行情数据列表</returns>
        IPagedCollection<MarketStatistic> GetList(IPagedSpecification<MarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询单条周行情
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>周行情数据</returns>
        WeekMarketStatistic GetWeekSingle(ISpecification<WeekMarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询周行情集合
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>周行情集合</returns>
        IPagedCollection<WeekMarketStatistic> GetWeekList(IPagedSpecification<WeekMarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询单条月行情数据
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>月行情数据</returns>
        MonthMarketStatistic GetMonthSingle(ISpecification<MonthMarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询月行情数据集合
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>月行情数据集合</returns>
        IPagedCollection<MonthMarketStatistic> GetMonthList(IPagedSpecification<MonthMarketStatistic> specification);


        /// <summary>
        /// 计算周行后将周行情信息写入到数据库
        /// </summary>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">时间</param>
        void Add(MarketType markettype, DateTime dt, Action<TaskExecutedStatus> updateAction = null);


        /// <summary>
        /// 计算周行后将周行情信息写入到数据库
        /// </summary>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">时间（根据该时间计算是第多少周)</param>
        void AddWeek(MarketType markettype, DateTime dt, Action<TaskExecutedStatus> updateAction = null);

        /// <summary>
        /// 计算月行情将月行情信息写入到数据库
        /// </summary>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">时间</param>
        void AddMonth(MarketType markettype, DateTime dt, Action<TaskExecutedStatus> updateAction = null);

        /// <summary>
        /// 根据周的开始时间和结束时间获取周的数据
        /// </summary>
        /// <param name="code">上市公司股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="tuple">时间类型Tuple，周的开始时间和结束时间</param>
        /// <returns>周的weekMarketStatistic的集合</returns>
        IEnumerable<WeekMarketStatistic> GetWeekList(string code, MarketType markettype, Tuple<DateTime, DateTime> tuple);

        /// <summary>
        /// 获取单条的周数据
        /// </summary>
        /// <param name="code">上市公司股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">时间</param>
        /// <returns>周数据对象</returns>
        WeekMarketStatistic GetWeekSingle(string code, MarketType markettype, DateTime dt);


        /// <summary>
        /// 根据市场和时间删除数据
        /// </summary>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">时间</param>
        void DeleteDayData(MarketType markettype, DateTime dt);
    }
}
